package com.adcc.eoss.cawebservice;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringUtil {

	private static DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public static String buildErrorMsg(String errCode, String errMessage) {
		String result = StringBuilder("{\"error-code\":\"", errCode,
				"\",\"error-message\":\"", errMessage, "\"}");
		return result;
	}

	public static String StringBuilder(String... args) {
		StringBuilder result = new StringBuilder();
		for (int i = 0; i < args.length; i++) {
			result.append(args[i]);
		}
		return result.toString();
	}

	public static String DateToString(Date date) {
        String str = "";
		if (date != null){
        	str = sdf.format(date);
        }
		return str;
	}

	public static java.sql.Date StringToSqlDate(String stringDate){
		Date date = null;   
		try {  
	            date = sdf.parse(stringDate);   
	        } catch (ParseException e) {  
	            e.printStackTrace();  
	        } 
		date = java.sql.Date.valueOf(stringDate);
		return (java.sql.Date) date;
	}
}
